/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kasgroup2;

import java.util.Date;
import java.util.HashMap;
import kasgroup2.UIKASGroup2;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author Atli, Benjamin & Jógvan
 */
public class KASGroup2 {

    private static CoreHandler coreHandler = new CoreHandler();
    
    public static CoreHandler getCoreHandlerInstance() { 
        return coreHandler; 
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        SetUILookAndFeel();
        LoadDemoData();
        InitUI();
    }

    //http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html
    private static void SetUILookAndFeel() {
        try {
            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Metal".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
                //System.out.println(info.getName());
            }
        } catch (Exception e) {
            
        }
    }

    private static void InitUI() {
        UIKASGroup2 uiKas = new UIKASGroup2();
        uiKas.setVisible(true);
        uiKas.pack();
    }

    private static void LoadDemoData() {
        //Create speakers
        Speaker speakerRoi = new Speaker("Rói Eliasen");
        Speaker speakerBartal = new Speaker("Bartal Clementsen");
        Speaker speakerHans = new Speaker("Hans F. Blaasværd");
        //Create activities
        Activity activityStoraDimun = new Activity("Stóra Dímun", "Útferð til Stóra Dímun", 1000.0, "heit klæðir við.", new Date(), new Date());
        Activity activityMenan = new Activity("Mentan", "Mentanartiltak í sjónleikarahúsinum", 200.0, "verið mentaði!", new Date(), new Date());
        Activity activityShopping = new Activity("Shoppingtúrur", "Shoppingtúrur havnina runt. Brúki pengarnar hjá manninum.", 5000.0, "brúki allar pengarnar!", new Date(), new Date(2));
        //Create conferences
        Conference confForritan = new Conference("Forritan", 1000.0, "Rúm 1, Samkoman, Marknagil 4, Tórshavn", "Læra at forrita í Java", new Date(), new Date(), true);
        Conference confSkipan = new Conference("KT í Virkinum", 2000.0, "Rúm 3, Samkoman, Marknagil 4, Tórshavn", "Læra at byggja góðar KT loysnir", new Date(), new Date(), true);
        Conference confKtVirki = new Conference("Skipanarmenning", 1500.0, "Rúm 2, Samkoman, Marknagil 4, Tórshavn", "KT í virkinum", new Date(), new Date(), true);
        //Add subjects to the speakers
        speakerRoi.addSubject("Domain Models", "Introduction to Domain Models");
        speakerRoi.addSubject("Use Cases", "How to write a fully dressed Use Case");
        speakerBartal.addSubject("Loops & Arrays", "For, for each, while, do-while, etc.");
        speakerBartal.addSubject("Inheritance & Polymorphism", "...");
        speakerBartal.addSubject("Databases", "MSSQL - An introduction to Microsoft SQL");
        speakerBartal.addSubject("Algorithms & Datastructures", "Write better software.");
        speakerHans.addSubject("Robots n' stuff", "Prepare for awesomeness!");
        //Add speakers to the conferences
        confForritan.addPerson(speakerBartal);
        confForritan.addPerson(speakerHans);
        confSkipan.addPerson(speakerRoi);
        confKtVirki.addPerson(speakerRoi);
        //Create roomservices
        RoomService rsBreakfast = new RoomService("Breakfest delivery", "The waiter will deliver breakfast to your door every morning.", 150);
        RoomService rsBreakfast2 = new RoomService("Breakfest delivery", "The waiter will deliver breakfast to your door every morning.", 175);
        //Create hotels
        HashMap<Room, Integer> hafniaRooms = new HashMap<Room, Integer>();
        hafniaRooms.put(new Room(EnumRoomType.STANDARD_SINGLE, 800, rsBreakfast), 38);
        hafniaRooms.put(new Room(EnumRoomType.STANDARD_DOUBLE, 1000, rsBreakfast), 18);
        hafniaRooms.put(new Room(EnumRoomType.SUITE_XL, 1200, rsBreakfast), 1);
        Hotel hotelHafnia = new Hotel(1, "Hotel Hafnia", "Áarvegur 4-10, Tórshavn", hafniaRooms); //57
        
        HashMap<Room, Integer> foroyarRooms = new HashMap<Room, Integer>();
        foroyarRooms.put(new Room(EnumRoomType.STANDARD_SINGLE, 900, rsBreakfast2), 50);
        foroyarRooms.put(new Room(EnumRoomType.STANDARD_DOUBLE, 1100, rsBreakfast2), 54);
        foroyarRooms.put(new Room(EnumRoomType.SUITE_XL, 1300, rsBreakfast2), 2);
        Hotel hotelForoyar = new Hotel(2, "Hotel Føroyar", "Oyggjarvegur 45, Tórshavn", foroyarRooms); //106
        
        /*Hotel hotelKerjalon = new Hotel("Hotel Kerjalon", "Oyggjarvegur 45, Tórshavn", 22);
        Hotel hotelKlaksvik = new Hotel("Hotel Klaksvík", "Víkavegur 38, Klaksvík", 26);
        Hotel hotelStreym = new Hotel("Hotel Streym", "Yviri við Strond 19, Tórshavn", 26);
        Hotel hotelOravik = new Hotel("Hotel Øravík", "Øravík, Suðuroy", 16);*/
        //Add hotels to the conferences
        confForritan.addHotel(hotelHafnia);
        confForritan.addHotel(hotelForoyar);
        confKtVirki.addHotel(hotelForoyar);
        confSkipan.addHotel(hotelHafnia);
        //Add activity to the conferences
        confForritan.addActivity(activityStoraDimun);
        confForritan.addActivity(activityMenan);
        confKtVirki.addActivity(activityStoraDimun);
        confSkipan.addActivity(activityStoraDimun);
        confSkipan.addActivity(activityShopping);
        //Add the speakers the system
        coreHandler.addSpeaker(speakerRoi);
        coreHandler.addSpeaker(speakerBartal);
        coreHandler.addSpeaker(speakerHans);
        //Add hotels to the system
        coreHandler.addHotel(hotelHafnia);
        coreHandler.addHotel(hotelForoyar);
        /*coreHandler.addHotel(hotelKerjalon);
        coreHandler.addHotel(hotelKlaksvik);
        coreHandler.addHotel(hotelStreym);
        coreHandler.addHotel(hotelOravik);*/
        //Add conferences to the system
        coreHandler.addConference(confForritan);
        coreHandler.addConference(confKtVirki);
        coreHandler.addConference(confSkipan);
        //Add activities to the system
        coreHandler.addActivity(activityStoraDimun);
        coreHandler.addActivity(activityMenan);
        coreHandler.addActivity(activityShopping);
        
        /*for(Speaker s : coreHandler.getSpeakerList()) {
            System.out.println("Speaker: " + s.getName());
            for(Subject sub : s.getSubjectList()) {
                System.out.println("\t"+sub.getName() + " - " + sub.getDescription());
            }
        }*/
    }
}
